// import * as echarts from '../../../ec-canvas/echarts';
const app = getApp();
let echarts = app.echarts;
function initChart(canvas, width, height) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height
  });
  canvas.setChart(chart);
  var rate = 30;
  var data = {
    max: 300,
    rate: 20
  }
  var labelArr = [0, 10, 100, 240, 300];
  var endFix = '';
  var option = {
    tooltip: {
      formatter: parseFloat(rate)
    },
    series: [{
      name: '业务指标',
      type: 'gauge',
      startAngle: 180,
      endAngle: 0,
      radius: "100%",
      axisLine: {
        show: true,
        // 属性lineStyle控制线条样式
        lineStyle: {
          width: 10,
          color: [[0.16, '#009100'], [0.32, '#00EC00'], [0.48, '#F9F900'], [0.64, '#FF8000'], [0.8, '#F75000'], [1, '#A23400']]
        }
      },
      splitLine: {
        show: false,
      },
      axisTick: {
        show: false,
      },
      axisLabel: {
        show: false,
      },
      pointer: {
        length: '25px',
        width: '3px',
      },
      detail: {
        offsetCenter: [0, '-120%'],
        fontSize: 1,
        formatter: '{value}'
      },
      data: [
        { value: 45 }
      ]
    }]
  };

  chart.setOption(option, true);

  return chart;
}

Page({
  onShareAppMessage: function (res) {
    return {
      title: 'ECharts 可以在微信小程序中使用啦！',
      path: '/pages/index/index',
      success: function () { },
      fail: function () { }
    }
  },
  data: {
    ec: {
      onInit: initChart
    }
  },

  onReady() {
  }
});
